<?php

namespace Kateba\SiteBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Answer
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="Kateba\SiteBundle\Entity\AnswerRepository")
 */
class Answer {

    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var \Kateba\SiteBundle\Entity\Question
     *
     * @ORM\ManyToOne(targetEntity="\Kateba\SiteBundle\Entity\Question", inversedBy="answers")
     * @ORM\JoinColumn(name="question_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)
     */
    private $question;

    /**
     * @var \Kateba\UserBundle\Entity\User
     *
     * @ORM\ManyToOne(targetEntity="\Kateba\UserBundle\Entity\User", inversedBy="answers")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)
     */
    private $user;

    /**
     * @var string
     * @Assert\NotBlank
     * @ORM\Column(name="answer", type="text")
     */
    private $answer;

    /**
     * @var boolean
     *
     * @ORM\Column(name="isAdmin", type="boolean")
     */
    private $isAdmin = false;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="createdAt", type="datetime")
     */
    private $createdAt;

    public function __construct() {
        $this->createdAt = new \DateTime();
    }

    public function __toString() {
        return (string) $this->answer;
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId() {
        return $this->id;
    }

    /**
     * Set answer
     *
     * @param string $answer
     * @return Answer
     */
    public function setAnswer($answer) {
        $this->answer = $answer;

        return $this;
    }

    /**
     * Get answer
     *
     * @return string
     */
    public function getAnswer() {
        return $this->answer;
    }

    /**
     * Set createdAt
     *
     * @param \DateTime $createdAt
     * @return Answer
     */
    public function setCreatedAt($createdAt) {
        $this->createdAt = $createdAt;

        return $this;
    }

    /**
     * Get createdAt
     *
     * @return \DateTime
     */
    public function getCreatedAt() {
        return $this->createdAt;
    }

    /**
     * Set isAdmin
     *
     * @param boolean $isAdmin
     * @return Answer
     */
    public function setIsAdmin($isAdmin) {
        $this->isAdmin = $isAdmin;

        return $this;
    }

    /**
     * Get isAdmin
     *
     * @return boolean
     */
    public function getIsAdmin() {
        return $this->isAdmin;
    }

    /**
     * Set question
     *
     * @param \Kateba\SiteBundle\Entity\Question $question
     * @return Answer
     */
    public function setQuestion(\Kateba\SiteBundle\Entity\Question $question) {
        $this->question = $question;

        return $this;
    }

    /**
     * Get question
     *
     * @return \Kateba\SiteBundle\Entity\Question
     */
    public function getQuestion() {
        return $this->question;
    }

    /**
     * Set user
     *
     * @param \Kateba\UserBundle\Entity\User $user
     * @return Answer
     */
    public function setUser(\Kateba\UserBundle\Entity\User $user) {
        $this->user = $user;

        return $this;
    }

    /**
     * Get user
     *
     * @return \Kateba\UserBundle\Entity\User
     */
    public function getUser() {
        return $this->user;
    }

}